package com.ruoyi.smartcity.anfang.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.smartcity.anfang.domain.AnfangJiankong;
import com.ruoyi.smartcity.anfang.service.IAnfangJiankongService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 监控管理Controller
 * 
 * @author ruoyi
 * @date 2025-03-09
 */
@RestController
@RequestMapping("/smartcity/anfang/jiankong")
public class AnfangJiankongController extends BaseController
{
    @Autowired
    private IAnfangJiankongService anfangJiankongService;

    /**
     * 查询监控管理列表
     */
    @RequiresPermissions("anfang:jiankong:list")
    @GetMapping("/list")
    public TableDataInfo list(AnfangJiankong anfangJiankong)
    {
        startPage();
        List<AnfangJiankong> list = anfangJiankongService.selectAnfangJiankongList(anfangJiankong);
        return getDataTable(list);
    }

    /**
     * 导出监控管理列表
     */
    @RequiresPermissions("anfang:jiankong:export")
    @Log(title = "监控管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AnfangJiankong anfangJiankong)
    {
        List<AnfangJiankong> list = anfangJiankongService.selectAnfangJiankongList(anfangJiankong);
        ExcelUtil<AnfangJiankong> util = new ExcelUtil<AnfangJiankong>(AnfangJiankong.class);
        util.exportExcel(response, list, "监控管理数据");
    }

    /**
     * 获取监控管理详细信息
     */
    @RequiresPermissions("anfang:jiankong:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(anfangJiankongService.selectAnfangJiankongById(id));
    }

    /**
     * 新增监控管理
     */
    @RequiresPermissions("anfang:jiankong:add")
    @Log(title = "监控管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AnfangJiankong anfangJiankong)
    {
        return toAjax(anfangJiankongService.insertAnfangJiankong(anfangJiankong));
    }

    /**
     * 修改监控管理
     */
    @RequiresPermissions("anfang:jiankong:edit")
    @Log(title = "监控管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AnfangJiankong anfangJiankong)
    {
        return toAjax(anfangJiankongService.updateAnfangJiankong(anfangJiankong));
    }

    /**
     * 删除监控管理
     */
    @RequiresPermissions("anfang:jiankong:remove")
    @Log(title = "监控管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(anfangJiankongService.deleteAnfangJiankongByIds(ids));
    }
}
